<? include 'server_config.php'; 
if (isset($_COOKIE[$cookie_auto_login]))
{
	$cks = explode(":",$_COOKIE[$cookie_auto_login]);
	$user_idx = $cks[0];
	$dbkey = hash("sha512", $_COOKIE[$cookie_auto_login], false);
	$sql = "
		DELETE FROM ndd_auto_login WHERE user_idx=$user_idx AND al_hash='$dbkey'
	";
	$result = mysql_query($sql,$connect);
	setcookie($cookie_auto_login, "", time()-3600);
}




if($_SESSION['user_idx'] != "")
{
?>	
	<script type='text/javascript'>
		location.href='ndd_cure.php';
	</script>
<?
		return;
}
?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
	<title>NextDoorDoctor : 넥스트도어닥터</title>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <link rel="Stylesheet" type="text/css" href="./css/nddNotLogin.css" />
	<script type="text/javascript" src="./js/jquery-1.6.2.min.js"></script>
	<script type="text/javascript" src="./js/region.js" ></script>
	<script>
	
	function blank_clear(input_str)
	{
		if($('#'+input_str).val()=="")
		{
		
			$('#'+input_str).css('background','transparent');
			
			
		}
		else
		{
		
			$('#'+input_str).css('background','#ffffff');
		
		}
	}
	</script>
</head>

 <body>
	<div id='wrapper'>
	
		<div id="contents">
			<div style="position:absolute;top:4px;left:77px;width:165px;height:43px;cursor:pointer;" onclick="location.href='ndd_main.php';">
				<span>
				</span>
			</div>

			<form name="form_login" action="login_proc.php"  method="post" enctype="multipart/form-data"  id="form_login" >
	
	
	
			<div style="position:absolute;top:12px;left:530px;width:120px;height:28px;cursor:pointer;"  onclick="find_pw_popup_open();">
				<span>
					<!--비밀번호 분실시 -->
					
					
					
				</span>
			</div>
			
					
			<div style="position:absolute;top:14px;left:665px;width:122px;height:17px;">
				<span><input type='text' name='login_mail' id='user_mail'  style="background:transparent;border:0px; width:122px;" value="" onkeyup="blank_clear('user_mail');">
				</span>
			</div>
			<div style="position:absolute;top:14px;left:803px;width:122px;height:17px;">
				<span><input type='password' name='login_pwd' id='user_pwd'  style="background:transparent;border:0px; width:122px;" value="" onkeyup="blank_clear('user_pwd');"  onkeydown="if(event.keyCode==13) document.getElementById('form_login').submit();">
				</span>
			</div>
			
			
			<div style="position:absolute;top:12px;left:935px;width:72px;height:28px;cursor:pointer;"  onclick="form_login.submit();">
				<span>
					<!--input type='text' style="background:transparent;border:0px; width:68px;" value="" onkeyup="this.value='';"  onkeydown="this.value='';if(event.keyCode==13) document.getElementById('form_login').submit();"-->
				</span>
			</div>
			
			<div style="position:absolute;top:14px;left:1020px;width:122px;height:17px;">
				<span><input type="checkbox" name="auto_login" id="auto_login_checkbox"><label for="auto_login_checkbox">자동 로그인</label></span>
			</div>
			</form>
	
			<form name="fwrite" action="register_proc.php"  method="post" enctype="multipart/form-data"  id="fwrite">
			

			<div style="position:absolute;top:253px;left:725px;width:290px;height:18px;">
				<span><input type='text' name='new_user_mail' id='new_user_mail'  style="background:transparent;border:0px; width:290px;" value="">
				</span>
			</div>
			<div style="position:absolute;top:283px;left:725px;width:290px;height:18px;">
				<span><input type='password' name='new_user_pw' id='new_user_pw'  style="background:transparent;border:0px; width:290px;" value="">
				</span>
			</div>
			<div style="position:absolute;top:313px;left:725px;width:290px;height:18px;">
				<span><input type='password' name='new_user_pw_confirm' id='new_user_pw_confirm'  style="background:transparent;border:0px; width:290px;" value="">
				</span>
			</div>
			<div style="position:absolute;top:343px;left:725px;width:290px;height:18px;">
				<span><input type='text' name='new_user_nickname' id='new_user_nickname'  style="background:transparent;border:0px; width:290px;" value="">
				</span>
			</div>
			<div style="position:absolute;top:374px;left:721px;width:50px;height:18px;">
				<span><select name='new_user_sex' id='new_user_sex'  style="background:#ffffff;border:0px; width:40px;height:22px;" value="">
					<option value='F'>여</option>
					<option value='M'>남</option>
				</select>
				</span>
			</div>
			<div style="position:absolute;top:374px;left:843px;width:50px;height:18px;">
				<span><select name='new_user_birthyear' id='new_user_birthyear'  style="background:#ffffff;border:0px; width:65px;height:22px;" value="">
					<?
						for($i=2011;$i>1900;$i--)
						{
							?>
						<option value='<? echo $i;?>'><? echo $i;?></option>
						<?
						}
							?>
				</select>
				</span>
			</div>


			<div style="position:absolute;top:404px;left:721px;width:100px;height:18px;">
				<span>
					<select name="wr_sido" 
					style="background:#ffffff;border:0px; width:90px;height:22px;"
					OnChange="changeRegion(fwrite)"></select>

				</span>
			</div>
			<div style="position:absolute;top:404px;left:823px;width:100px;height:18px;">
				<span>
					<select name="wr_gugun" style="background:#ffffff;border:0px; width:90px;height:22px;"></select>
					<script language="javascript">
					<!--
					// php 변수 wr_sido와 wr_gugun에 저장된 값을 기본 선택값으로 초기화한다.
					// wr_sido와 wr_gugun에 저장된 값이 없으면 첫 항목으로 초기화한다.
					var swr_sido = "<?=$row[1]?>"; // php 변수를 자바스크립트 변수로 저장 - 현재 선택된 시도.
					var swr_gugun = "<?=$row[2]?>"; // php 변수를 자바스크립트 변수로 저장 - 현재 선택된 시군구.
					initRegion();
					changeRegion(fwrite);
					-->
					</script>

				</span>
			</div>

			<div style="position:absolute;top:455px;left:721px;width:82px;height:32px;cursor:pointer;" onclick="register_popup_send();">
				<span> &nbsp;
				</span>
			</div>
			</form>
			
			<div style="position:absolute;top:390px;left:77px;width:178px;height:27px;cursor:pointer;" onclick="location.href='ndd_p1.php';">
				<span> &nbsp;
				</span>
			</div>


			<div style="position:absolute;top:650px;left:77px;width:178px;height:27px;">
				<span id='copyright_left'>NextDoorDoctor © 2011
				</span>
			</div>
			<div style="position:absolute;top:650px;left:784px;width:233px;height:27px;text-align:right;">
				<span id="copyright_right">
				<a href='ndd_p1.php'>회사소개</a> <a href='ndd_p2.php'>개인정보보호</a> <a href='ndd_p3.php'>이용약관</a> <a href='ndd_p4.php'>고객센터</a>
				</span>
			</div>

		</div>
	</div>
	<iframe name="ifrm_hidden" style="display:none;"></iframe>
	
	
	<div id="popup_base" style="position:absolute;background:black; width:100%;opacity:0.65;display:none;">
	</div>

	<div id="popup_user_lost" style="position:absolute;background-image: url(./img/user_lost.png); width:584px;height:237px; repead:no;display:none;">
		<div style="position:absolute;top:190px;left:125px;width:250px;height:20px;">
			<span>
				<input type='text' id="find_pw_user_name" style="background:transparent;border:0px; width:250px;">
			</span>
		</div>
		<div style="position:absolute;top:187px;left:385px;width:73px;height:32px;cursor:pointer;" onclick="find_pw_popup_send();"></div>
		<div style="position:absolute;top:0px;left:550px;width:32px;height:32px;cursor:pointer;" onclick="find_pw_popup_close();"></div>
			
	</div>

	<div id="popup_register" style="position:absolute;background-image: url(./img/popup_register.png); width:584px;height:234px; repead:no;display:none;">
		<div style="position:absolute;top:190px;left:125px;width:250px;height:20px;">
			<span>
			</span>
		</div>
		<div style="position:absolute;top:0px;left:550px;width:32px;height:32px;cursor:pointer;" onclick="register_popup_close();"></div>
		<div style="position:absolute;top:185px;left:214px;width:160px;height:30px;cursor:pointer;" onclick="register_popup_close();"></div>
			
	</div>
<? /*
	INSERT INTO ndd_user VALUES ('', '$user_name', password('$user_password'), '$user_nickname', '$wr_sido', '$wr_gugun', 'N', '".$generated_key."', '0', CURRENT_TIMESTAMP);";
	*/ ?>		
	<script>
	blank_clear('user_mail');
	
	
	
	function register_popup_open()
	{
		$('#popup_base').height(document.body.scrollHeight);
		$('#popup_base').width(document.body.scrollWidth);
		
		$('#popup_base').css("left",0);
		$('#popup_base').css("top",0);
		$('#popup_base').css("display","");
		
		$('#popup_register').css("left",document.body.scrollWidth/2-292);
		$('#popup_register').css("top",document.body.scrollHeight/2-118);
		
		$('#popup_register').css("display","");
	
	}
	
	function register_popup_send()
	{
		var string = $("#fwrite").serialize(); 
		
		$.ajax(
		{
			type: "POST",
			url: "register_proc.php",
			data: string,
			
			success: function(msg) {
				if(msg==1)
				{
//					alert("success");
					
					register_popup_open();
					
				}
				else
				{
					alert(msg);
				}
				//alert(msg);*/
				//alert($('#find_pw_user_name').val()+' 으로 비밀번호 재설정 메일이 전송되었습니다.');
				//find_pw_popup_close();
				

			}
			
		})		
	}

	function register_popup_close()
	{
		$('#popup_base').css("display","none");
		
		$('#popup_register').css("display","none");
	
		location.href="ndd_cure.php";
	}	
		
	function find_pw_popup_open()
	{
		$('#popup_base').height(document.body.scrollHeight);
		$('#popup_base').width(document.body.scrollWidth);
		
		$('#popup_base').css("left",0);
		$('#popup_base').css("top",0);
		$('#popup_base').css("display","");
		
		$('#popup_user_lost').css("left",document.body.scrollWidth/2-292);
		$('#popup_user_lost').css("top",document.body.scrollHeight/2-118);
		
		$('#popup_user_lost').css("display","");
	
	}
	

	function find_pw_popup_send()
	{
		$.ajax(
		{
			type: "POST",
			url: "user_lost_proc.php",
			data: "user_name=" + $('#find_pw_user_name').val(),
			
			success: function(msg) {
				/*if(msg==1)
				{
					alert("success");
				}
				else
				{
					alert("error");
				}
				alert(msg);*/
				alert($('#find_pw_user_name').val()+' 으로 비밀번호 재설정 메일이 전송되었습니다.');
				find_pw_popup_close();
				

			}
			
		})		
	}
	
	function find_pw_popup_close()
	{
		$('#popup_base').css("display","none");
		
		$('#popup_user_lost').css("display","none");
	
	}	
	</script>
</body>
</html>
